package com.xiao.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
 * 接口统一返回包装类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {


        private String code;

        private String msg;//错误信息
        //返回的数据
        private Object data;

         //标记是否成功
        private Boolean flag;


    public static Result success(){
            return new Result(Constants.CODE_200,"",null,true);
        }

    public  static Result success(Object data){
        return new Result(Constants.CODE_200, "", data,true);
    }

    public  static Result error(String code, String msg){
        return new Result(code, msg, null,false);
    }

    public  static Result error(){
        return new Result(Constants.CODE_500, "系统繁忙,请稍后再试!",null,false);
    }

}
